package com.esms.bean;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;

import com.esms.struts.service.FinancialRateService;

/**
 * A data access object (DAO) providing persistence and search support for
 * Enterprisefinancialrate entities. Transaction control of the save(), update()
 * and delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.esms.bean.Enterprisefinancialrate
 * @author MyEclipse Persistence Tools
 */

public class EnterprisefinancialrateDAO extends BaseHibernateDAO {
	private EnterprisefinancialrateDAO() {}
	public static EnterprisefinancialrateDAO $ = new EnterprisefinancialrateDAO(); 
	
	private static final Log log = LogFactory
			.getLog(EnterprisefinancialrateDAO.class);
	// property constants
	public static final String FFENTERPRISE_ID = "ffenterpriseId";
	public static final String ENDOWMENT_RATE_C = "endowmentRateC";
	public static final String MEDICAL_RATE_C = "medicalRateC";
	public static final String SUSPENSION_RATE_C = "suspensionRateC";
	public static final String WORKPLACE_RATE_C = "workplaceRateC";
	public static final String MATERNITY_RATE_C = "maternityRateC";
	public static final String HOUSINGFUND_RATE_C = "housingfundRateC";
	public static final String HOUSINGFUND_SRATE_C = "housingfundSRateC";
	public static final String ENDOWMENT_RATE_E = "endowmentRateE";
	public static final String MEDICAL_RATE_E = "medicalRateE";
	public static final String SUSPENSION_RATE_E = "suspensionRateE";
	public static final String WORKPLACE_RATE_E = "workplaceRateE";
	public static final String MATERNITY_RATE_E = "maternityRateE";
	public static final String HOUSINGFUND_RATE_E = "housingfundRateE";
	public static final String HOUSINGFUND_SRATE_E = "housingfundSRateE";

	public void save(Enterprisefinancialrate transientInstance) {
		log.debug("saving Enterprisefinancialrate instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(Enterprisefinancialrate persistentInstance) {
		log.debug("deleting Enterprisefinancialrate instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public Enterprisefinancialrate findById(java.lang.Integer id) {
		log.debug("getting Enterprisefinancialrate instance with id: " + id);
		try {
			Enterprisefinancialrate instance = (Enterprisefinancialrate) getSession()
					.get("com.esms.bean.Enterprisefinancialrate", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(Enterprisefinancialrate instance) {
		log.debug("finding Enterprisefinancialrate instance by example");
		try {
			List results = getSession().createCriteria(
					"com.esms.bean.Enterprisefinancialrate").add(
					Example.create(instance)).list();
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Enterprisefinancialrate instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from Enterprisefinancialrate as model where model."
					+ propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByFfenterpriseId(Object ffenterpriseId) {
		return findByProperty(FFENTERPRISE_ID, ffenterpriseId);
	}

	public List findByEndowmentRateC(Object endowmentRateC) {
		return findByProperty(ENDOWMENT_RATE_C, endowmentRateC);
	}

	public List findByMedicalRateC(Object medicalRateC) {
		return findByProperty(MEDICAL_RATE_C, medicalRateC);
	}

	public List findBySuspensionRateC(Object suspensionRateC) {
		return findByProperty(SUSPENSION_RATE_C, suspensionRateC);
	}

	public List findByWorkplaceRateC(Object workplaceRateC) {
		return findByProperty(WORKPLACE_RATE_C, workplaceRateC);
	}

	public List findByMaternityRateC(Object maternityRateC) {
		return findByProperty(MATERNITY_RATE_C, maternityRateC);
	}

	public List findByHousingfundRateC(Object housingfundRateC) {
		return findByProperty(HOUSINGFUND_RATE_C, housingfundRateC);
	}

	public List findByHousingfundSRateC(Object housingfundSRateC) {
		return findByProperty(HOUSINGFUND_SRATE_C, housingfundSRateC);
	}

	public List findByEndowmentRateE(Object endowmentRateE) {
		return findByProperty(ENDOWMENT_RATE_E, endowmentRateE);
	}

	public List findByMedicalRateE(Object medicalRateE) {
		return findByProperty(MEDICAL_RATE_E, medicalRateE);
	}

	public List findBySuspensionRateE(Object suspensionRateE) {
		return findByProperty(SUSPENSION_RATE_E, suspensionRateE);
	}

	public List findByWorkplaceRateE(Object workplaceRateE) {
		return findByProperty(WORKPLACE_RATE_E, workplaceRateE);
	}

	public List findByMaternityRateE(Object maternityRateE) {
		return findByProperty(MATERNITY_RATE_E, maternityRateE);
	}

	public List findByHousingfundRateE(Object housingfundRateE) {
		return findByProperty(HOUSINGFUND_RATE_E, housingfundRateE);
	}

	public List findByHousingfundSRateE(Object housingfundSRateE) {
		return findByProperty(HOUSINGFUND_SRATE_E, housingfundSRateE);
	}

	public List findAll() {
		log.debug("finding all Enterprisefinancialrate instances");
		try {
			String queryString = "from Enterprisefinancialrate";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public Enterprisefinancialrate merge(
			Enterprisefinancialrate detachedInstance) {
		log.debug("merging Enterprisefinancialrate instance");
		try {
			Enterprisefinancialrate result = (Enterprisefinancialrate) getSession()
					.merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(Enterprisefinancialrate instance) {
		log.debug("attaching dirty Enterprisefinancialrate instance");
		try {
			getSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(Enterprisefinancialrate instance) {
		log.debug("attaching clean Enterprisefinancialrate instance");
		try {
			getSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
}